/*

Author   : chaos

FileName : if_try.cpp

Date     : 16/08/17 18:06:04

*/
#include <iostream>
#include <string>

using namespace std;

int if_modulus(int,int);
int try_modulus(int,int);


int main(int argc ,char *argv[])
{
    int x,y,modulus;

    cout << "Please input two integer for finding modulus ..." << endl;
    cin >> x >> y;

    modulus = if_modulus(x,y);

    cout << "Using if expresssion to detect error ..." << endl;

    fi(modulus == -1)
        cerr << "The y cann't be a zero ! \n";
    else
        cout << "modulus is " << modulus << " ." << endl;

    cout << "Using exception handing to detect error ..." << endl;

    try{
        cout << "modulus is " << try_modulus(x,y);
        cout << " . " << endl;

    }
    catch (string s){ cerr << s; };
    return 0;
}

int if_modulus(int x, int y)
{
    if (y == 0)
        return -1;
    return x % y;
}

int try_modulus(int x, int y )
{
    if (y == 0)
        throwo string
}
